package com.yunhe.merchants.service.impl;

import com.yunhe.common.model.mybatis.PageResult;
import com.yunhe.merchants.constant.MyProjectConsts;
import com.yunhe.merchants.domain.MyProject;
import com.yunhe.merchants.model.FilterCondition;
import com.yunhe.merchants.model.IntentionProjectUpload;
import com.yunhe.merchants.service.IIntentionProjectService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.*;

/**
 * @Author: DongWenYu
 * @Date: 2021/5/7 21:17
 */
@Service
public class IntentionProjectServiceImpl extends MyProjectServiceImpl implements IIntentionProjectService {

    private  List<String> status = new ArrayList<>();

    private static final Logger logger = LoggerFactory.getLogger(IntentionProjectServiceImpl.class);

    @PostConstruct
    private void init(){
        Collections.addAll(status,MyProjectConsts.COMPANY_STATUS.Intention.value());
    }

    @Override
    public PageResult selectByFilterCondition(FilterCondition filterCondition, Long userId , int page, int size) {
        return super.selectByFilterCondition(filterCondition,status,userId,page,size);
    }

    @Override
    public void upload(List<IntentionProjectUpload> intentionProjectUploads , Long userId , Long stationId) {
        //upload转Do
        List<MyProject> myProjects =convertUploadToDo(intentionProjectUploads,userId,stationId);
        //批量插入
        myProjectRepository.insertBatch(myProjects);
        logger.info("导入{}条数据进入数据库",myProjects.size());
    }

    @Override
    public List<MyProject> export(String ids , FilterCondition filterCondition) {
        return super.export(ids,filterCondition,status);
    }


}
